<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width| initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    邮箱：<input type="text" id="email"><span></span><br>
    数字：<input type="text" id="number"><span></span>
</body>
<script>
    var oemail = document.getElementById("email");
    var num = document.getElementById('number')

    oemail.onblur = function(){
        //邮箱的规则：自定义@自定义.org
        //邮箱的规则：数字字母下换线，6~18 @ 数字字母 1~18 . 字母 2~4位
        var reg = /^[0-9a-zA-Z]{5,12}@(126|163|qq)\.(sina|cn|com|net)$/;

        if(reg.test(this.value)){
            this.nextElementSibling.innerHTML = "验证成功";
        }else{
            this.nextElementSibling.innerHTML = "邮箱的规则：数字大小写字母，5~12 @ 126|163|qq . sina|cn|qq|net";
        }
    }

    num.onblur = function(){
        var reg = /^(\d|\d{2}|1\d{2}|2[0-4]\d|25[0-5])$/;

        if(reg.test(this.value)){
            this.nextElementSibling.innerHTML = "验证成功";
        }else{
            this.nextElementSibling.innerHTML = "请输入0-255之间数值";
        }
    }

    
</script>
</html>